package com.leaf.spring_five.jms;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;


/**
 * 异步接收 – 消息驱动的 POJOs
 */
public class ExampleListener implements MessageListener{

	
	
	@Override
	public void onMessage(Message message) {
		if(message instanceof TextMessage){
			try {
				System.out.println(((TextMessage)message).getText());
			} catch (JMSException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new IllegalArgumentException("Message must be of type TextMessage");
		}
	}

}
